package Data;

import edu.uci.ics.crawler4j.url.WebURL;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class CrawlStat {
    private int totalProcessedPages;
    private long totalLinks;
    private Map<Integer, WebURL> visitedLinks;

    public CrawlStat() {
        this.visitedLinks = new ConcurrentHashMap<Integer, WebURL>();
        this.totalLinks = this.totalProcessedPages = 0;
    }

    public int getTotalProcessedPages() {
            return totalProcessedPages;
    }

    public void setTotalProcessedPages(int totalProcessedPages) {
            this.totalProcessedPages = totalProcessedPages;
    }

    public void incProcessedPages() {
            this.totalProcessedPages++;
    }

    public long getTotalLinks() {
            return totalLinks;
    }

    public void setTotalLinks(long totalLinks) {
            this.totalLinks = totalLinks;
    }

    public void incTotalLinks(int count) {
            this.totalLinks += count;
    }

    public void addWebURL(WebURL url) {
        this.visitedLinks.put(url.hashCode(), url);
    }

    public boolean containsWebURL(WebURL url) {
        return this.visitedLinks.containsKey(url.hashCode());
    }
}